//
// Created by francklinson on 2021/11/24 AT 10:37.
// May Saint Diana bless you!
//

#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <functional>
#include <climits>
#include <string>

using namespace std;

class Solution {
public:
    int longestPalindrome(string s) {
        unordered_map<char, int> counter;
        for (const char &x: s) {
            ++counter[x];
        }
        int ans = 0;
        for (auto &p: counter) {
            int num = p.second;
            ans += (num / 2) * 2; // 每次都加偶数个
        }
        ans += ans < s.size() ? 1 : 0;  // 如果有多的，可以往最中间放一个
        return ans;
    }
};

int main() {
    Solution solution;
    cout << solution.longestPalindrome("abccccdd") << endl;
    return 0;
}

